<style>
  .import {
    opacity: 0;
    position: absolute;
    width: 69px;
    height: 38px;
    margin-left: -10px;
  }

  .layui-badge-rim {
    height: 20px;
    border-width: 1px;
    border-style: solid;
    background-color: #eef4f5;
    font: 14px Helvetica Neue, Helvetica, PingFang SC, Tahoma, Arial, sans-serif;
    color: #6e667d;
  }

  #productPic_path > img {
    max-height: 350px;
    max-width: 700px;
  }

  .material-body {
    display: flex;
    height: 100% !important;
    padding: 0 15px 0 0 !important;
  }

  .material-nav {
    width: 102px;
    background: rgba(0, 0, 0, .01);
  }

  .material-nav .nav-cell {
    padding: 10px 5px 10px 10px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
  }

  .material-nav .nav-cell:hover {
    color: #333;
    transition: all .3s;
  }

  .material-nav .nav-cell.nav-active {
    color: #333;
  }

  .material-nav .nav-cell.nav-active::before {
    content: '';
    display: inline-block;
    height: 14px;
    width: 3px;
    background: #1BA70E;
    position: absolute;
    left: 0;
  }

  .material-body .body-left {
    width: 340px;
    height: 100%;
    overflow: auto;
  }

  .body-left .layui-tab-content {
    height: 100%;
    padding: 0;
    flex: 1;
    border-right: 1px solid #e6e6e6;
  }

  .body-left .layui-tree {
    padding: 5px;
  }

  .body-left .layui-tab {
    height: 100%;
    color: #999;
    display: flex;
    overflow: auto;
  }

  .body-left .layui-tab-title li {
    padding: 0 10px;
  }

  .material-body .body-right {
    width: calc(100% - 355px);
    padding: 15px 0 15px 15px;
  }

  .layui-tree-emptyText {
    padding-top: 5px;
  }

  .body-right xm-select {
    min-height: 32px;
    line-height: 32px;
  }

</style>
<style>
  form[lay-filter="productAddForm"] .tdInputOne > input {
    display: inline-block;
    width: 30%;
  }

  form[lay-filter="productAddForm"] .tdSelectOne > .layui-form-select {
    width: 19%;
    display: inline-block;
    margin-bottom: 5px;
    margin-right: 5px;
  }

  form[lay-filter="productAddForm"] .inputBorderNone {
    border-color: transparent;
    outline-color: transparent;
  }

  form[lay-filter="productAddForm"] .inputBorderNone:hover {
    border-color: transparent !important;
    outline-color: transparent;
  }

  form[lay-filter="productAddForm"] .inputBorderNone:focus {
    border-color: transparent !important;
    outline-color: transparent;
  }

  div[lay-id='productDetailTable'] .layui-table-body .layui-table-cell {
    height: 32px;
    line-height: 32px;
  }

  .layui-form-label.w-120 {
    width: 120px;
  }

  .layui-col-md4 {
    margin-bottom: 10px;
  }

  .layui-form-label.w-150 {
    width: 150px;
  }
</style>
<form lay-filter="productDetailForm" class="layui-form model-form" id="productDetailForm">
  <input name="id" type="hidden"/>
  <div class="layui-form-item">
    <div class="layui-col-md4">
      <label class="layui-form-label w-120"><span style="color: red">*</span>所属类型</label>
      <div class="layui-input-inline">
        <input id="productTypeId"
               name="productTypeId" type="hidden">
        <div class="layui-input-inline mr0" id="productTypeIdType"></div>
      </div>
    </div>
    <div class="layui-col-md4">
      <label class="layui-form-label w-120">物料名称</label>
      <div class="layui-input-inline">
        <input name="skuName" id="skuName" class="layui-input borderNone" type="text"
        />
      </div>
    </div>
    <div class="layui-col-md4">
      <label class="layui-form-label w-120">物料编号</label>
      <div class="layui-input-inline">
        <input name="skuCode" id="skuCode" class="layui-input borderNone" type="text"/>
      </div>
    </div>
    <div class="layui-col-md4">
      <label class="layui-form-label w-120">自定义分类</label>
      <div class="layui-input-inline">
        <select id="productCategoryId" name="productCategoryId" lay-filter="productCategoryId"
                class="layui-input borderNone"></select>
      </div>
    </div>
    <div class="layui-col-md4">
      <label class="layui-form-label w-120">基础单位</label>
      <div class="layui-input-inline">
        <input name="baseUnit" id="baseUnit" type="hidden"/>
        <input name="baseUnitName" disabled id="baseUnitName" class="layui-input borderNone" type="text"
        />
      </div>
    </div>
    <div class="layui-col-md4">
      <label class="layui-form-label w-120">历史料号</label>
      <div class="layui-input-inline">
        <input name="oldSkuCode" id="oldSkuCode" class="layui-input borderNone" type="text"
        />
      </div>
    </div>


    <div class="layui-col-md4">
      <label class="layui-form-label w-120"><span style="color: red">*</span>主计量方式</label>
      <div class="layui-input-inline">
        <select id="mainCalWay" name="mainCalWay" lay-filter="mainCalWay"
                class="layui-input borderNone"></select>
      </div>
    </div>

    <div class="layui-col-md4">
      <label class="layui-form-label w-120"><span style="color: red">*</span>主计量单位</label>
      <div class="layui-input-inline">
        <select id="mainUnitId" name="mainUnitId" lay-filter="mainUnitId"
                class="layui-input borderNone"></select>
      </div>
    </div>

    <div class="layui-col-md4">
      <label class="layui-form-label w-150">主换算率*(基础单位数)</label>
      <div class="layui-input-inline">
        <input name="mainUnitRate" id="mainUnitRate" class="layui-input borderNone"
               type="text"/>
      </div>
    </div>

    <div class="layui-col-md4">
      <label class="layui-form-label w-120"><span style="color: red">*</span>辅助计量方式</label>
      <div class="layui-input-inline">
        <select id="subCalWay" name="subCalWay" lay-filter="subCalWay"
                class="layui-input borderNone"></select>
      </div>
    </div>

    <div class="layui-col-md4">
      <label class="layui-form-label w-120"><span style="color: red">*</span>辅计量单位</label>
      <div class="layui-input-inline">
        <select id="subUnitId" name="subUnitId" lay-filter="subUnitId"
                class="layui-input borderNone"></select>
      </div>
    </div>

    <div class="layui-col-md4">
      <label class="layui-form-label w-150">辅换算率*(基础单位数)</label>
      <div class="layui-input-inline">
        <input name="subUnitRate" id="subUnitRate"
               class="layui-input borderNone" type="text"/>
      </div>
    </div>


    <div class="layui-col-md4">
      <label class="layui-form-label w-120 ">规格码</label>
      <div class="layui-input-inline">
        <input name="skuSpec" id="skuSpec" class="layui-input borderNone" type="text"/>
      </div>
    </div>
    <div class="layui-col-md4">
      <label class="layui-form-label w-120">历史规格码</label>
      <div class="layui-input-inline">
        <input name="oldSpecCode" id="oldSpecCode" class="layui-input borderNone" type="text"
        />
      </div>
    </div>
    <div class="layui-col-md4">
      <label class="layui-form-label w-120">备注</label>
      <div class="layui-input-inline">
        <input name="remark" id="remark" class="layui-input borderNone" type="text"/>
      </div>
    </div>


    <div class="layui-col-md4">
      <label class="layui-form-label w-120">物料图片</label>
      <div class="layui-input-inline">
        <div id="productPicBtn1" class="layui-btn" style="float: left;">
          <i class="layui-icon">&#xe681;</i>上传图片
        </div>
        <input name="productPic" type="hidden" class="layui-input" lay-verify="" id="productPic"/>
        <img id="productPicPreview" style="margin-top: 10px;width: 150px;height: 100px;display: none;"/>
      </div>
    </div>
  </div>
  <div class="layui-tab layui-tab-brief" lay-filter="test-hash">
    <ul class="layui-tab-title">
      <li class="layui-this" lay-id="11">规格参数</li>
      <li lay-id="22">属性参数</li>
      <li lay-id="33">库存管理设置</li>
    </ul>
    <div class="layui-tab-content">
      <div class="layui-tab-item layui-show">
        <div id="tabSpecParam"></div>
      </div>
      <div class="layui-tab-item">
        <div id="tabAttributeParam"></div>
      </div>
      <div class="layui-tab-item">
        <div class="layui-col-md4">
          <label class="layui-form-label w-120">计价币种</label>
          <div class="layui-input-inline">
            <select id="priceCurrency" name="priceCurrency" lay-filter="priceCurrency"
                    class="layui-input borderNone"></select>
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label w-120"><span style="color: red">*</span>默认税率</label>
          <div class="layui-input-inline">
            <input name="taxRate" id="taxRate" class="layui-input borderNone"
                   type="text"/>
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label w-120">成本核算</label>
          <div class="layui-input-inline">
            <select id="costCheckType" name="costCheckType" lay-filter="costCheckType"
                    class="layui-input borderNone">
            </select>
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label w-120">安全库存数</label>
          <div class="layui-input-inline">
            <input name="warningQuantity" id="warningQuantity" class="layui-input borderNone"
                   type="text"/>
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label w-120">是否可以销售</label>
          <div class="layui-input-inline">
            <select id="sellStatus" name="sellStatus" lay-filter="sellStatus"
                    class="layui-input borderNone">
            </select>
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label w-120">质保期(天)</label>
          <div class="layui-input-inline">
            <input name="warrantyDay" id="warrantyDay" class="layui-input borderNone"
                   type="text"/>
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label w-120">呆滞预警时长(天)</label>
          <div class="layui-input-inline">
            <input name="lethargyThreshold" id="lethargyThreshold"
                   class="layui-input borderNone" type="text"/>
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label w-120">出入库方式</label>
          <div class="layui-input-inline">
            <select id="exitStorageType" name="exitStorageType" lay-filter="exitStorageType"
                    class="layui-input borderNone"></select>
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label w-120">预入仓库</label>
          <div class="layui-input-inline">
            <select id="warehouseId" name="warehouseId" lay-filter="warehouseId"
                    class="layui-input borderNone"></select>
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label w-120">是否质检</label>
          <div class="layui-input-inline">
            <select id="checkStatus" name="checkStatus" lay-filter="checkStatus"
                    class="layui-input borderNone">
            </select>
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label w-120">是否先进先出</label>
          <div class="layui-input-inline">
            <select id="inoutStatus" name="inoutStatus" lay-filter="inoutStatus"
                    class="layui-input borderNone">
            </select>
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label w-120">是否批次管理</label>
          <div class="layui-input-inline">
            <select id="batchStatus" name="batchStatus" lay-filter="batchStatus"
                    class="layui-input borderNone">
            </select>
          </div>
        </div>

        <div class="layui-col-md4">
          <label class="layui-form-label w-120">是否料箱管理</label>
          <div class="layui-input-inline">
            <select id="boxStatus" name="boxStatus" lay-filter="boxStatus"
                    class="layui-input borderNone"></select>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="layui-form-item" style="margin-bottom: 20px;">

  </div>
  <div class="layui-form-item text-right">
    <div class="right-btn">
      <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
      <button class="layui-btn" lay-filter="productDetailSubmit" lay-submit>提交</button>
    </div>
  </div>
</form>
<script type="text/html" id="specParamInputTab">
  <div class="layui-col-md4">
    <label class="layui-form-label w-120">{{d.name}}</label>
    <div class="layui-input-inline">
      <!-- 使用动态生成的唯一ID -->
      {{# if(d.style === 'single'){ }}
      <select id="productSpecList{{d.type}}_{{ d.id }}" name="{{d.type}}"
              lay-filter="productSpecList{{d.type}}_{{ d.id }}" class="layui-input borderNone">
      </select>
      {{# } else { }}
      <input type="text" id="productSpecList1{{d.type}}_{{ d.id }}" name="{{d.type}}"
             class="layui-input borderNone"/>
      {{# } }}
    </div>
  </div>

</script>


<script>
  layui.use(['layer', 'form', 'table', 'admin', 'upload', 'tree', 'laytpl'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var table = layui.table;
    var config = layui.config;
    var admin = layui.admin;
    var upload = layui.upload;
    var laytpl = layui.laytpl;
    data=parentData.data
    console.log(parentData)
    $('#tabSpecParam').empty()
    $('#tabAttributeParam').empty()
    // $('#productPicBtn1').click(() => {
    imgUpload()
    // });
    if (data) {
      //获取产品明细
      admin.reqSync('enterprise/product/admin/productDetailWMS/get?productDetailId=' + data.id, {}, function (res) {
        layer.closeAll('loading');
        if (res.code == 200) {
          // 所属类型
          admin.initDataSelectTree(true, 'enterprise/product/admin/productType/getTreeDataForLast', null, 'productTypeIdType', res.data.productTypeId, "所属类型", "productTypeId", function (obj) {
            $('#tabSpecParam').empty()
            $('#tabAttributeParam').empty()
            // admin.contentRmpty(['tabSpecParam','tabAttributeParam'])
            let id = obj.change[0].value
            xxx(id)
          });
          xxx(res.data.productTypeId, res.data)

          // admin.initDataSelectTree(true, 'enterprise/product/admin/productType/getTreeDataForLast', null, 'productTypeIdType', res.data.productTypeId, "所属类型", "productTypeId",)
          admin.getDictList("mainCalWay", "product_unit_cal_way", res.data.mainCalWay, "主计量方式");
          admin.getDictList("subCalWay", "product_unit_cal_way", res.data.subCalWay, "复制计量方式");
          //物料类别性质
          // admin.getDictList("materialNature", "sys_product_type_nature", res.data.materialNature, "物料类别性质");
          //物料分类
          admin.initDataSelect("enterprise/product/admin/productCategory/list", {limit: 9999}, "productCategoryId", res.data.productCategoryId, "自定义分类", null, null);
          // //品牌
          // admin.initDataSelect("enterprise/product/admin/productBrand/list", {limit: 9999}, "brandId", res.data.brandId, "品牌", null, null);
          // //库存计量方式
          // admin.getDictList("calculateWay", "sys_product_detail_calculate_way", res.data.calculateWay, "库存计量方式");
          // //计量单位
          // admin.getDictList("unitId", "sys_product_detail_calculate_unit", res.data.unitId, "计量单位");
          // //基础单位
          // admin.getDictList("baseUnit", "sys_product_detail_base_unit", res.data.baseUnit, "基础单位");
          // //计价币种
          // admin.getDictList("priceCurrency", "sys_product_detail_price_currency", res.data.priceCurrency, "计价币种");
          // //是否自产产品
          // admin.getDictList("selfProductStatus", "sys_yes_no", res.data.selfProductStatus, "是否自产产品");
          // //产品性质
          // admin.getDictList("productNature", "product_nature", res.data.productNature, "产品性质");
          //成本核算
          admin.getDictList("costCheckType", "product_detail_cost_check_type", res.data.costCheckType, "成本核算");
          //是否可以销售
          admin.getDictList("sellStatus", "sys_yes_no", res.data.sellStatus, "是否可以销售");
          //是否质检
          admin.getDictList("checkStatus", "sys_yes_no", res.data.checkStatus, "是否质检");
          //出入库方式
          admin.getDictList("exitStorageType", "product_detail_exit_storage_type", res.data.exitStorageType, "出入库方式");
          //预入仓库
          admin.initDataSelect("enterprisecab/warehouse/admin/warehouse/list", {limit: 9999}, "warehouseId", res.data.warehouseId, "预入仓库", null, null);
          //计价币种
          admin.getDictList("priceCurrency", "sys_product_detail_price_currency", res.data.priceCurrency, "计价币种");
          // //数据来源
          // admin.getDictList("dataSource", "sys_product_detail_data_source", res.data.dataSource, "数据来源");
          // //是否一物一码
          // admin.getDictList("thingCodeStatus", "sys_yes_no", res.data.thingCodeStatus, "是否一物一码");
          //是否批次管理
          admin.getDictList("batchStatus", "sys_yes_no", res.data.batchStatus, "是否批次管理");
          //是否先进先出
          admin.getDictList("inoutStatus", "sys_yes_no", res.data.inoutStatus, "是否先进先出");
          //是否料箱管理
          admin.getDictList("boxStatus", "sys_yes_no", res.data.boxStatus, "是否料箱管理");
          if (res.data.productPic) {
            $('#productPic').val(res.data.productPic); // Store the image URL in hidden input
            $('#productPicPreview').attr('src', res.data.productPic).show(); // Show image preview

          }

          // //产品属性
          // admin.getDictList("assemblyNature", "product_assembly_nature", res.data.assemblyNature, "产品属性");
          // window.setTimeout(() => {
          form.val('productDetailForm', res.data);
          form.render("select")
          //     console.log('res.data', res.data)
          // }, 1000)


        } else {
          layer.msg(res.msg, {icon: 2});
        }
      }, 'GET');
    } else {
      admin.initDataSelectTree(true, 'enterprise/product/admin/productType/getTreeDataForLast', null, 'productTypeIdType', null, "所属类型", "productTypeId", function (obj) {
        $('#tabSpecParam').empty()
        $('#tabAttributeParam').empty()
        // admin.contentRmpty(['tabSpecParam','tabAttributeParam'])
        let id = obj.change[0].value
        xxx(id)

      });
      // 成本核算
      admin.getDictList("costCheckType", "product_detail_cost_check_type", null, "成本核算");

      // 计量方式
      admin.getDictList("mainCalWay", "product_unit_cal_way", null, "主计量方式");
      admin.getDictList("subCalWay", "product_unit_cal_way", null, "复制计量方式");
      //物料类别性质
      admin.getDictList("materialNature", "sys_product_type_nature", null, "物料类别性质");
      //所属类别
      admin.initDataSelect("enterprise/product/admin/productType/list", {limit: 9999}, "productTypeId", null, "所属类别", null, null);
      //物料分类
      admin.initDataSelect("enterprise/product/admin/productCategory/list", {limit: 9999}, "productCategoryId", null, "物料分类", null, null);
      //品牌
      admin.initDataSelect("enterprise/product/admin/productBrand/list", {limit: 9999}, "brandId", null, "品牌", null, null);
      //库存计量方式
      admin.getDictList("calculateWay", "sys_product_detail_calculate_way", null, "库存计量方式");
      //计量单位
      admin.getDictList("unitId", "sys_product_detail_calculate_unit", null, "计量单位");
      //基础单位
      // admin.getDictList("", "sys_product_detail_base_unit", null, "基础单位");
      //计价币种
      admin.getDictList("priceCurrency", "sys_product_detail_price_currency", null, "计价币种");
      //是否自产产品
      // admin.getDictList("selfProductStatus", "sys_yes_no", null, "是否自产产品");
      admin.getDictList("exitStorageType", "product_detail_exit_storage_type", null, "出入库方式");
      //预入仓库
      admin.initDataSelect("enterprisecab/warehouse/admin/warehouse/list", {limit: 9999}, "warehouseId", null, "预入仓库", null, null);

      let formFieldNameList =
              {
                selfProductStatus: '是否自产产品',
                sellStatus: '是否可以销售',
                thingCodeStatus: '是否一物一码',
                batchStatus: '是否批次管理',
                inoutStatus: '是否先进先出',
                checkStatus: '是否质检',
                boxStatus: '是否料箱管理'


              }
      admin.getDictList(Object.keys(formFieldNameList),
              "sys_yes_no", null, Object.values(formFieldNameList));

      //产品性质
      admin.getDictList("productNature", "product_nature", null, "产品性质");
      //是否可以销售
      // admin.getDictList("sellStatus", "sys_yes_no", null, "是否可以销售");
      //数据来源
      admin.getDictList("dataSource", "sys_product_detail_data_source", null, "数据来源");
      //是否一物一码
      // admin.getDictList("thingCodeStatus", "sys_yes_no", null, "是否一物一码");
      //是否批次管理
      // admin.getDictList("batchStatus", "sys_yes_no", null, "是否批次管理");
      //是否先进先出
      // admin.getDictList("inoutStatus", "sys_yes_no", null, "是否先进先出");
      //产品属性
      admin.getDictList("assemblyNature", "product_assembly_nature", null, "产品属性");
    }
    // 表单提交事件
    form.on('submit(productDetailSubmit)', function (d) {
      console.log('data', d.field)

      var productDetailSpecList = []; //规格数组
      $("[name='tabSpecParam']").each(function () {
        var id = $(this).attr('id').split('_')[1]
        console.log(111, $(this).attr('id'))
        productDetailSpecList.push({
          productSpecId: id,
          productSpecValue: $(this).val()
        }); // 将值添加到数组中
      });

      var productDetailAttributeList = []; // 属性数组
      $("[name='tabAttributeParam']").each(function () {
        var id = $(this).attr('id').split('_')[1]
        productDetailAttributeList.push({
          productAttrId: id,
          productAttrValue: $(this).val()
        }); // 将值添加到数组中
      });
      let formData = {productDetailSpecList, productDetailAttributeList, ...d.field}
      admin.req(data ? 'enterprise/product/admin/productDetail/update' : 'enterprise/product/admin/productDetail/add', JSON.stringify(formData), function (res) {
        layer.closeAll('loading');
        if (res.code == 200) {
          layer.msg(res.msg, {icon: 1});
          table.reload('productDetailTable');
          layer.closeAll('page');
        } else {
          layer.msg(res.msg, {icon: 2});
        }
      }, data ? 'PUT' : 'POST', true, 'application/json; charset=utf-8');
      return false;
    });
    function imgUpload() {
      upload.render({
        elem: '#productPicBtn1',
        url: config.upload_url + 'uploadFile',
        accept: 'file',
        headers: {Authorization: 'Bearer ' + config.getToken()},
        // acceptMime: 'image/*',
        exts: 'jpg|jpeg|png|gif',
        done: function (res) {
          // On successful upload
          if (res.code === 200) {
            const url = res.data.url
            $('#productPic').val(url); // Store the image URL in hidden input
            $('#productPicPreview').attr('src', url).show(); // Show image preview
            layer.msg('图片上传成功');
            console.log(111, res)
          } else {
            layer.msg('图片上传失败: ' + res.msg);
          }
        },
        error: function () {
          // On upload failure
          layer.msg('上传失败，请重试');
        }
      });
    }
    function xxx(productTypeId, ProductTypeData) {
      admin.req('enterprise/product/admin/productType/getProductTypeVoById', {productTypeId}, (resdata) => {
        //计量单位集合
        const productUnitList = resdata.data.productUnitList
        if(productUnitList.find(v=>v.isBaseUnit)){
          $(`#baseUnit`).val(productUnitList.find(v=>v.isBaseUnit).id)
          $(`#baseUnitName`).val(productUnitList.find(v=>v.isBaseUnit).name)
        }
        // 传入计量方式 和计量单位下拉框实例id
        function wayForUnit(wayId, unitId) {
          $(`#${unitId}`).empty();
          // 如果有data 表示要回显
          if (ProductTypeData) {
            wayIdVal = ProductTypeData[wayId]
            admin.initDataSelect(productUnitList.filter(v=>v.calWay == wayIdVal),null,unitId,ProductTypeData[unitId])
          } else {
            $(`#${wayId}`).val('')
            form.render("select")
          }
          // 计量方式点击事件 更新计量单位下拉框
          form.on(`select(${wayId})`, function (data) {
            $(`#${unitId}`).empty();
            if (data.value) {
              admin.initDataSelect(productUnitList.filter(v=>v.calWay == data.value),null,unitId)
            }
            form.render("select")
          });
        }
        wayForUnit('mainCalWay', 'mainUnitId')
        wayForUnit('subCalWay', 'subUnitId')

        // 传入需要动态渲染的list、父盒子id，如果传入obj 代表要回显
        function tabAppendFun(list, id, obj) {
          list.forEach((item, index) => {
            // 渲染模板
            laytpl(specParamInputTab.innerHTML).render({
              type: id,
              ...item,
            }, function (html) {
              $(`#${id}`).append(html); // 将渲染后的 HTML 插入到容器中
            });
            // single 为单选 其他为 文本
            if (item.style == 'single') {
              if (item.specValues || item.attrValues) {
                const ValuesList = new Set(item.specValues ? item.specValues.split(',') : item.attrValues.split(','))
                console.log('ValuesList', ValuesList)
                $(`#${`productSpecList${id}_${item.id}`}`).append(new Option('请选择', '')); // 动态添加 <option> 元素
                ValuesList.forEach(option => {
                  $(`#${`productSpecList${id}_${item.id}`}`).append(new Option(option, option)); // 动态添加 <option> 元素
                });
                if (obj) {
                  let objData = ProductTypeData[obj.list].find(v => v[obj.id] == item.id)
                  if (objData) {
                    $(`#${`productSpecList${id}_${item.id}`}`).val(objData[obj.value]) //给选择框赋值
                  }
                }
              }
            } else {
              if (obj) {
                let objData = ProductTypeData[obj.list].find(v => v[obj.id] == item.id)
                if (objData) {
                  $(`#${`productSpecList1${id}_${item.id}`}`).val(objData[obj.value]) //给选择框赋值
                }
              }


            }
          });
          form.render('select');
        }

        // 如果传入了ProductTypeData 表示需要回显
        console.log(33333, resdata)
        if (ProductTypeData) {
          tabAppendFun(ProductTypeData.productSpecList, 'tabSpecParam', {
            list: 'productDetailSpecList',
            id: 'productSpecId',
            value: 'productSpecValue'
          })
          tabAppendFun(ProductTypeData.productAttributeList, 'tabAttributeParam', {
            list: 'productDetailAttributeList',
            id: 'productAttrId',
            value: 'productAttrValue'
          })
        } else {
          tabAppendFun(resdata.data.productSpecList, 'tabSpecParam')
          tabAppendFun(resdata.data.productAttributeList, 'tabAttributeParam')
        }

        form.render("select")
      })
    }

  })


</script>
